<template>
	<view class="next-swipe-action">
		<slot></slot>
	</view>
</template>

<script>
	import props from './props.js';
	import mpMixin from '../../../../libs/mixin/mpMixin.js';
	import mixin from '../../../../libs/mixin/mixin.js';

	export default {
		name: 'next-swipe-action',
		mixins: [mpMixin, mixin, props],
		data() {
			return {}
		},
		provide() {
			return {
				swipeAction: this
			}
		},
		computed: {
			parentData() {
				return [this.autoClose]
			}
		},
		watch: {
			parentData() {
				if (this.children.length) {
					this.children.map(child => {
						typeof(child.updateParentData) === 'function' && child.updateParentData()
					})
				}
			},
		},
		created() {
			this.children = []
		},
		methods: {
			closeOther(child) {
				if (this.autoClose) {
					this.children.map((item, index) => {
						if (child !== item) {
							item.closeHandler()
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
